<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>05-Docker常用命令 | 知识库</title>
    <meta name="generator" content="VuePress 1.9.2">
    <link rel="icon" href="/vuepress-theme-vdoing-doc/img/favicon.ico">
    <noscript><meta http-equiv="refresh" content="0; url=https://www.youngkbt.cn/noscript/"><style>.theme-vdoing-content { display:none }</noscript>
    <meta name="description" content="一个基于VuePress的 知识管理">
    <meta name="keywords" content="vuepress,theme,blog,vdoing">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css" as="style"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/76.f684a067.js" as="script"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/10.d2937c56.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/11.67567365.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/12.74e8c324.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/13.2376fcd7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/14.57ef5c33.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/15.44e7c0ba.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/16.c2fb4c44.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/17.af212389.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/18.1e6acac7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/19.54653ac9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/20.920cc499.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/21.37128fe3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/22.8f68a2f2.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/23.7b9f1ba6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/24.12adc291.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/25.cfe381e5.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/26.9cf879f6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/27.4e6190ea.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/28.1e22fc79.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/29.c57e047d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/3.cdcce428.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/30.21a95474.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/31.ce97e6e3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/32.cdb45d73.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/33.fd95e780.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/34.cd49a408.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/35.fe128161.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/36.02043ece.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/37.02eee249.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/38.4650dec6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/39.04fb7652.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/4.c02b1e5f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/40.7b51f807.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/41.1df513a9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/42.92a82cec.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/43.363fceef.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/44.867b24fd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/45.89f64bfa.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/46.3a4c53d8.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/47.b8a31c80.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/48.7a584b38.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/49.98345029.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/5.cb45b2c7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/50.6a0b68f4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/51.8945cdf6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/52.6583e327.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/53.f6987dfc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/54.cca012f3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/55.8c58cf5c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/56.23e08364.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/57.08b54de0.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/58.131ee23e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/59.45637607.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/6.c97c5dc9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/60.fe9c5dd1.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/61.39ad8fda.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/62.ede47d34.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/63.4bb3e179.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/64.23f955bc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/65.77ffc240.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/66.a4503c94.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/67.bd3d6fa6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/68.a003ac59.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/69.64c66f41.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/7.1e88af32.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/70.87dfbf7d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/71.02806218.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/72.54e30335.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/73.002db3b4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/74.e577570e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/75.e610b3c9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/77.8be17062.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/78.cabc6873.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/79.83febd7c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/8.91701106.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/80.19e3b7ca.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/81.1b4cafb3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/82.752ef803.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/83.460cd49b.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/84.377a221f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/85.016eaf98.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/86.604c5deb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/87.d3a3662d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/88.0cf7f581.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/89.40b002bd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/9.94309dfb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/90.086847f8.js">
    <link rel="stylesheet" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/vuepress-theme-vdoing-doc/" class="home-link router-link-active"><img src="/vuepress-theme-vdoing-doc/img/logo.png" alt="知识库" class="logo"> <span class="site-name can-hide">知识库</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="nav-link">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="nav-link">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="nav-link">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="nav-link">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <div class="sidebar-slot sidebar-slot-top">
  <a href="http://apifox.cn/a103xugaoyi" target="_blank">
<!--    <img src="https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/431669861564_.2470ykdcpbds.jpg" alt="npm" class="no-zoom" style="width: 100%;border-radius: 2px;">-->
<!--    <p style="text-align: center;margin: 0;color: #999;font-size: 12px;">(进入注册为作者充电)</p>-->
  </a></div> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>基础</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="sidebar-link">02-Docker安装与卸载</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" aria-current="page" class="active sidebar-link">05-Docker常用命令</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/vuepress-theme-vdoing-doc/pages/43b85f/" class="sidebar-link">overlay2占用空间太大</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/vuepress-theme-vdoing-doc/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>docker</span></li><li data-v-06225672><span data-v-06225672>基础</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://gitee.com/wenlongjia" target="_blank" title="作者" class="beLink" data-v-06225672>Insist</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-05-16</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">05-Docker常用命令<!----></h1> <div class="page-slot page-slot-top">
    <div class="wwads-cn wwads-horizontal page-wwads" data-id="136"></div>
    <style>
      .page-wwads{
        width:100%!important;
        min-height: 0;
        margin: 0;
      }
      .page-wwads .wwads-img img{
        width:80px!important;
      }
      .page-wwads .wwads-poweredby{
        width: 40px;
        position: absolute;
        right: 25px;
        bottom: 3px;
      }
      .wwads-content .wwads-text, .page-wwads .wwads-text{
        height: 100%;
        padding-top: 5px;
        display: block;
      }
  </style>
  </div> <div class="theme-vdoing-content content__default"><h1 id="常用命令"><a href="#常用命令" class="header-anchor">#</a> 常用命令</h1> <h3 id="基本"><a href="#基本" class="header-anchor">#</a> 基本</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 查看当前docker版本</span>
<span class="token function">docker</span> <span class="token parameter variable">-v</span>
<span class="token function">docker</span> verison

<span class="token comment"># 查看docker系统信息</span>
<span class="token function">docker</span> info
</code></pre></div><h3 id="开发常用"><a href="#开发常用" class="header-anchor">#</a> 开发常用</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 列出容器 -- 仅运行的容器</span>
<span class="token function">docker</span> <span class="token function">ps</span> 
<span class="token comment"># 列出容器 -- 包含停止的容器</span>
<span class="token function">docker</span> <span class="token function">ps</span> <span class="token parameter variable">-a</span>

<span class="token comment"># 查看当前本地所有镜像</span>
<span class="token function">docker</span> images

<span class="token comment"># 搜索镜像</span>
<span class="token function">docker</span> search 镜像
<span class="token comment"># 获取镜像</span>
<span class="token function">docker</span> pull 镜像仓库地址
<span class="token comment"># 上传镜像</span>
<span class="token function">docker</span> push 镜像仓库地址

<span class="token comment"># 运行容器</span>
<span class="token comment"># –name 定义一个容器的名字，如果在执行docker run时没有指定Name，那么deamon会自动生成一个随机数字符串当做UUID。</span>
<span class="token comment"># -d 标识是让 docker 容器在后台运行。</span>
<span class="token comment"># -p 标识通知 Docker 将容器内部使用的网络端口映射到我们使用的主机上。</span>
<span class="token comment"># -m 限制容器内存100m</span>
<span class="token function">docker</span> run <span class="token parameter variable">--name</span> nginx <span class="token parameter variable">-d</span> <span class="token parameter variable">-p</span> <span class="token number">8080</span>:80 <span class="token parameter variable">-m</span> 100m nginx

<span class="token comment"># 停止容器 </span>
<span class="token function">docker</span> stop 容器ID/容器名
<span class="token comment"># 启动容器</span>
<span class="token function">docker</span> start 容器ID/容器名
<span class="token comment"># 重启容器</span>
<span class="token function">docker</span> restart 容器ID/容器名

<span class="token comment"># 杀掉一个运行中的容器</span>
<span class="token function">docker</span> <span class="token function">kill</span> <span class="token parameter variable">-s</span> KILL 容器ID/容器名

<span class="token comment"># 删除容器</span>
<span class="token function">docker</span> <span class="token function">rm</span> 容器ID/容器名
<span class="token comment"># 删除一个或多少容器。-f :通过SIGKILL信号强制删除一个运行中的容器-l :移除容器间的网络连接，而非容器本身-v :-v 删除与容器关联的卷</span>
<span class="token function">docker</span> <span class="token function">rm</span> <span class="token parameter variable">-f</span> xx、xx2

<span class="token comment"># 删除镜像 【 顺序：停止镜像里的容器，再删除容器，最后再删除镜像 】</span>
<span class="token function">docker</span> rmi 镜像id/镜像名


<span class="token comment"># 进入容器</span>
<span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> 容器ID/容器名 /bin/bash
<span class="token comment"># 以交互模式启动一个容器,在容器内执行/bin/bash命令</span>
<span class="token function">docker</span> run <span class="token parameter variable">-i</span> <span class="token parameter variable">-t</span> 容器ID/容器名 /bin/bash


<span class="token comment"># 查看容器日志 -t:显示时间戳</span>
<span class="token function">docker</span> logs <span class="token parameter variable">-f</span> <span class="token parameter variable">-t</span> 容器ID/容器名
<span class="token function">docker</span> logs <span class="token parameter variable">-fn10</span> <span class="token parameter variable">-t</span> 容器ID/容器名


<span class="token comment"># 构造镜像</span>
<span class="token comment"># 用法 docker build -t 镜像名称 .</span>
<span class="token function">docker</span> build <span class="token parameter variable">-t</span> docker_demo <span class="token builtin class-name">.</span>
</code></pre></div><h3 id="容器信息"><a href="#容器信息" class="header-anchor">#</a> 容器信息</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 查看 容器/镜像 元数据</span>
<span class="token function">docker</span> inspect 容器ID/容器名
<span class="token comment"># 查询容器内部ip地址</span>
<span class="token function">docker</span> inspect 容器ID/容器名 <span class="token operator">|</span> <span class="token function">grep</span> IPAddress
<span class="token comment"># 查看日志文件路径</span>
<span class="token function">docker</span> inspect <span class="token parameter variable">--format</span><span class="token operator">=</span><span class="token string">'{{.LogPath}}'</span> 容器ID/容器名
<span class="token comment"># 查看容器在 `/var/lib/docker/overlay2/` 下的数据目录</span>
<span class="token function">docker</span> inspect <span class="token parameter variable">-f</span> <span class="token string">'{{ .GraphDriver.Data.MergedDir }}'</span> 容器ID/容器名
<span class="token comment"># 查看容器映射的数据存放目录 -- 主要是看Mounts节点信息</span>
<span class="token function">docker</span> inspect <span class="token parameter variable">-f</span> <span class="token string">'{{ .Mounts }}'</span> 容器ID/容器名
</code></pre></div><h3 id="运维常用"><a href="#运维常用" class="header-anchor">#</a> 运维常用</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 列出所有的容器 ID</span>
<span class="token function">docker</span> <span class="token function">ps</span> <span class="token parameter variable">-aq</span>
<span class="token comment"># 停止所有的容器</span>
<span class="token function">docker</span> stop <span class="token variable"><span class="token variable">$(</span><span class="token function">docker</span> <span class="token function">ps</span> <span class="token parameter variable">-aq</span><span class="token variable">)</span></span>
<span class="token comment"># 删除所有的容器</span>
<span class="token function">docker</span> <span class="token function">rm</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">docker</span> <span class="token function">ps</span> <span class="token parameter variable">-aq</span><span class="token variable">)</span></span>
<span class="token comment"># 删除所有的镜像</span>
<span class="token function">docker</span> rmi <span class="token variable"><span class="token variable">$(</span><span class="token function">docker</span> images <span class="token parameter variable">-q</span><span class="token variable">)</span></span>

<span class="token comment"># 停止并删除指定容器</span>
<span class="token function">docker</span> <span class="token function">ps</span> <span class="token parameter variable">-a</span> <span class="token operator">|</span> <span class="token function">grep</span> 容器ID/容器名 <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $1}'</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token parameter variable">-i</span> <span class="token function">docker</span> stop <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token parameter variable">-i</span> <span class="token function">docker</span> <span class="token function">rm</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

<span class="token comment"># 删除镜像</span>
<span class="token comment"># docker images 获取所有images</span>
<span class="token comment"># grep -E &quot;xxxxx&quot; 筛选到特定的images</span>
<span class="token comment"># awk ‘ {print $3}’ 打印第三列 即image id列</span>
<span class="token comment"># uniq 检查及删除文本文件中重复出现的行列</span>
<span class="token comment"># xargs -I {} 多行转单行</span>
<span class="token comment"># docker rmi --force {} 删除所有指定镜像id</span>
<span class="token function">docker</span> images <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-E</span> <span class="token string">&quot;镜像id/镜像名&quot;</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $3}'</span> <span class="token operator">|</span> <span class="token function">uniq</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token parameter variable">-I</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token function">docker</span> rmi <span class="token parameter variable">--force</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
<span class="token comment"># ex: 删除镜像 `nginx:latest`</span>
<span class="token function">docker</span> images <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-E</span> nginx <span class="token operator">|</span> <span class="token function">grep</span> latest<span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $3}'</span> <span class="token operator">|</span> <span class="token function">uniq</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token parameter variable">-I</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token function">docker</span> rmi <span class="token parameter variable">--force</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>


<span class="token comment"># 删除所有停止的容器</span>
<span class="token function">docker</span> container prune

<span class="token comment"># 删除所有不使用的镜像</span>
<span class="token function">docker</span> image prune <span class="token parameter variable">--force</span> <span class="token parameter variable">--all</span>
<span class="token comment"># 或</span>
<span class="token function">docker</span> image prune <span class="token parameter variable">-f</span> <span class="token parameter variable">-a</span>


<span class="token comment"># 查看容器运行内存信息  【参数`mem_limit: 300m` # 最大使用内存】</span>
<span class="token function">docker</span> stats nginx
<span class="token comment"># CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O     BLOCK I/O     PIDS</span>
<span class="token comment"># 385a15a9724d   nginx     0.00%     1.961MiB / 100MiB   1.96%     656B / 0B   0B / 8.19kB   3</span>
</code></pre></div><h3 id="其它"><a href="#其它" class="header-anchor">#</a> 其它</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 查看镜像的创建历史</span>
<span class="token function">docker</span> <span class="token function">history</span> 镜像仓库地址
</code></pre></div></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/08/14, 13:28:01</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">02-Docker安装与卸载</div></a> <a href="/vuepress-theme-vdoing-doc/pages/43b85f/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">overlay2占用空间太大</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="prev">02-Docker安装与卸载</a></span> <span class="next"><a href="/vuepress-theme-vdoing-doc/pages/43b85f/">overlay2占用空间太大</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2024
    <span>Insist | MIT License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/76.f684a067.js" defer></script>
  </body>
</html>
